//
//  TweetMainController.m
//  Guazi
//
//  Created by koolearn on 11-4-26.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "TweetMainController.h"
#import "GuaziAppDelegate.h"

@implementation TweetMainController

/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
    }
    return self;
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}



/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
	[friendsTimelineController release];
	[ownerTimelineController release];
	[postViewController release];
	
}


- (void)dealloc {
	[friendsTimelineController release];
	[ownerTimelineController release];
	[postViewController release];
    [super dealloc];
}


-(void) showMenu: (UIBarButtonItem *) item
{
    UIActionSheet *menu = [[UIActionSheet alloc]
						   initWithTitle: @"请选择您要进行的操作"
                           delegate:self
                           cancelButtonTitle:@"取消"
                           destructiveButtonTitle:@"发布动态"
                           otherButtonTitles:@"我发布的动态", @"@我的动态", @"我的收藏", nil];
	[menu showFromTabBar:self.navigationController.tabBarController.tabBar];
    [menu release];
}


- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    [actionSheet release];
	if ( buttonIndex == 0 ) {
		//post
		[[GuaziAppDelegate getAppDelegate] post:self];
	}
	else if ( buttonIndex == 1 ) {
		//my's timeline
		GuaziAppDelegate* appDelegate = [GuaziAppDelegate getAppDelegate];
		User* owner = appDelegate.user;
		UserTimelineController* userTimeline = [[[UserTimelineController alloc] initWithUser:owner] autorelease];
		[self.navigationController pushViewController:userTimeline animated:true];
	}
	else if ( buttonIndex == 2 ) {
		//@me
		FriendsTimelineController* controller = [[[FriendsTimelineController alloc] init] autorelease];
		controller.tweetType = 2;
		[self.navigationController pushViewController:controller animated:true];
	}
	else if ( buttonIndex == 3 ) {
		//my's favorite
	}
}


@end
